<% scope ||= nil
   footer_extension ||= nil
   url_options ||= params_for(action: form_action)
   xhr = request.xhr? if xhr.nil?
   if active_scaffold_config.actions.include? form_action
     action_config = active_scaffold_config.send(form_action)
     multipart ||= action_config.multipart? unless local_assigns.key? :multipart
     columns ||= action_config.columns unless local_assigns.key? :columns
     persistent ||= action_config.persistent unless local_assigns.key? :persistent
     field_descriptions ||= action_config.field_descriptions
     if !local_assigns.key?(:floating_footer) && action_config.respond_to?(:floating_footer)
       floating_footer = action_config.floating_footer
     end
     if !local_assigns.key?(:add_locking_column) && action_config.respond_to?(:add_locking_column)
       add_locking_column = action_config.add_locking_column
     end
   else
     multipart ||= false
     columns ||= nil
     persistent ||= false
     field_descriptions ||= :show
   end
   floating_footer ||= false
   method ||= :post
   cancel_link = true if cancel_link.nil?
   submit_text ||= form_action
   apply_text ||= :"#{form_action}_apply"
   body_partial ||= 'form'
   form_id = element_form_id(action: form_action, id: @record&.id)
%>
<%=
options = {id: form_id,
           multipart: multipart,
           class: "as_form #{form_action} #{'floating-footer' if floating_footer} #{"descriptions-#{field_descriptions}" if field_descriptions != :show}",
           method: method,
           'data-loading' => defined?(loading) ? loading : true}
cancel_options = {class: 'as_cancel'}
cancel_options[:remote] = true if xhr # cancel link does nt have to care about multipart forms
if xhr && multipart # file_uploads
  form_remote_upload_tag url_options.merge(iframe: true), options
else
  options[:remote] = true if xhr && !multipart
  form_tag url_options, options
end
-%>
  <%= hidden_field :record, @record.class.locking_column if add_locking_column && @record.persisted? && @record.locking_enabled? %>
  <h4><%= headline -%></h4>

  <div id="<%= element_messages_id(action: form_action) %>" class="messages-container">
    <% unless xhr %>
      <p class="error-message message server-error" style="display:none;">
        <%= as_(:internal_error).html_safe %>
        <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
      </p>
    <% end %>
    <%= render 'form_messages' %>
  </div>

  <%= render body_partial, columns: columns, form_action: form_action, scope: scope %>

  <p class="form-footer">
    <%= submit_tag as_(submit_text), class: 'submit' if !persistent || persistent == :optional %>
    <%= submit_tag as_(apply_text), class: 'submit', name: 'dont_close' if persistent %>
    <%= link_to(as_(:cancel), main_path_to_return, cancel_options) if cancel_link %>
    <%= loading_indicator_tag(action: form_action, id: @record&.id) %>
    <%= render footer_extension, form_action: form_action if footer_extension %>
  </p>

</form>
